package com.hsgene.user.service.impl;

import com.hsgene.common.util.result.ApiResult;
import com.hsgene.user.dto.orginazation.OrganizationDto;
import com.hsgene.user.exception.OrganizationErrorCode;
import com.hsgene.user.persistence.OperationOrganizationRepository;
import com.hsgene.user.service.OperationOrganizationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author wangbing
 * @version 1.0, 2018/11/2
 */
@Service
public class OperationOrganizationServiceImpl implements OperationOrganizationService {

    @Resource
    private OperationOrganizationRepository operationOrganizationRepository;

    @Override
    public ApiResult<OrganizationDto> findOrganization(String orgId, String orgType) {
        OrganizationDto organization = operationOrganizationRepository.findOrganization(orgId, orgType);
        if (organization == null) {
            return ApiResult.fail(OrganizationErrorCode.ORG_NOT_EXISTED);
        }
        return ApiResult.succ(organization);
    }
}
